<?php

namespace app\admin\controller;

use app\lib\enum\Status;
use think\Controller;

class BaseController extends Controller
{
    protected function _initialize() {
        $data=[
            "webInfo"=>cache("webInfo"),
            "Status"=>[
                "on"=>Status::on,
                "off"=>Status::off
            ],
            "InstitutionRoleId"=>getInstitutionRoleId(),
        ];
        $this->view->share($data);
    }

    protected $beforeActionList=[
        "toLogin"=>['except'=>"login"]
    ];

    public function toLogin(){
        if(!isLogin()){
            $this->redirect("admin/admin/login");
        }
    }

    //指定返回信息
    public function uniteResponse($result,$successMsg){
        if($result!=1){
            $this->error($result);
        }else{
            $this->success($successMsg);
        }
    }

}
